package validate

import (
	"io"

	"github.com/asyncapi/parser-go/pkg/parser"
)

type Parser = func(io.Reader, io.Writer) error

type Cli struct {
	filePath string
}

func New(filePath string) Cli {
	return Cli{
		filePath: filePath,
	}
}

func (h Cli) NewParserAndReader() (Parser, io.Reader, error) {
	r, err := parser.NewReader(h.filePath)
	if err != nil {
		return nil, nil, err
	}
	p, err := parser.New()
	if err != nil {
		return nil, nil, err
	}

	return p, r, nil
}
